def usernameCheck(userName):
    length = len(userName)
    if length < 6 or length > 10:
        raise Exception("用户名长度必须为 6 ~ 10 位")
def passwordCheck(password):
    length = len(password)
    if length >= 8 and length <=16:
        if password.isalnum():
            if password.isdigit() or password.isalpha():
                raise Exception("密码须同时包含数字和字母！")
        else:
            raise Exception("密码只能包含数字和字母！")
    else:
        raise Exception("密码长度必须为 6 ~ 16 位！")

while True:
    try:
        userName = input("请输入用户名：")
        usernameCheck(userName)
        password = input("请输入密码：")
        passwordCheck(password)
        print("注册成功！")
        break
    except Exception as e:
        print(e)